import CountryCode from './countryCodes'

const postCodeRegex: Map<string, RegExp> = new Map([
  [CountryCode.AF, /^[0-9]{4}$/],
  [CountryCode.AX, /^(AX)?[0-9]{5}$/],
  [CountryCode.AL, /^[0-9]{4}$/],
  [CountryCode.DZ, /^[0-9]{5}$/],
  [CountryCode.AS, /^[0-9]{5}$/],
  [CountryCode.AD, /^AD[0-9]{3}$/],
  [CountryCode.AI, /^AI2640$/],
  [CountryCode.AQ, /^BIQQ1ZZ$/],
  [CountryCode.AR, /^[0-9]{4}$|^[a-zA-Z][0-9]{4}$|^[a-zA-Z][0-9]{4}[a-zA-Z]{3}$/],
  [CountryCode.AM, /^[0-9]{4}$/],
  [CountryCode.AU, /^[0-9]{4}$/],
  [CountryCode.AT, /^[0-9]{4}$/],
  [CountryCode.AZ, /^AZ[0-9]{4}$/],
  [CountryCode.BH, /^[0-9]{3,4}$/],
  [CountryCode.BD, /^[0-9]{4}$/],
  [CountryCode.BB, /^(BB)?[0-9]{5}$/],
  [CountryCode.BY, /^[0-9]{6}$/],
  [CountryCode.BE, /^[0-9]{4}$/],
  [CountryCode.BT, /^[0-9]{5}$/],
  [CountryCode.BO, /^[0-9]{4}$/],
  [CountryCode.BA, /^[0-9]{5}$/],
  [CountryCode.BR, /^[0-9]{8}$/],
  [CountryCode.VG, /^(VG)?[0-9]{4}$/],
  [CountryCode.IO, /^BBND1ZZ$/],
  [CountryCode.BN, /^[a-zA-Z]{2}[0-9]{4}$/],
  [CountryCode.BG, /^[0-9]{4}$/],
  [CountryCode.KH, /^[0-9]{5}$/],
  [CountryCode.CA, /^[ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z][ ]?[0-9][ABCEGHJ-NPRSTV-Z][0-9]$/],
  [CountryCode.CV, /^[0-9]{4}$/],
  [CountryCode.KY, /^KY[0-9]{5}$/],
  [CountryCode.TD, /^[0-9]{5}$/],
  [CountryCode.CL, /^[0-9]{7}$/],
  [CountryCode.CN, /^[0-9]{6}$/],
  [CountryCode.CX, /^[0-9]{4}$/],
  [CountryCode.CC, /^[0-9]{4}$/],
  [CountryCode.CO, /^[0-9]{6}$/],
  [CountryCode.CR, /^[0-9]{5}$/],
  [CountryCode.HR, /^[0-9]{5}$/],
  [CountryCode.CU, /^[0-9]{5}$/],
  [CountryCode.CY, /^[0-9]{4}$/],
  [CountryCode.CZ, /^[0-9]{5}$/],
  [CountryCode.DK, /^(DK){0,1}\\d{4}$/],
  [CountryCode.DO, /^[0-9]{5}$/],
  [CountryCode.EC, /^[0-9]{6}$/],
  [CountryCode.EG, /^[0-9]{5}$/],
  [CountryCode.SV, /^[0-9]{4}$/],
  [CountryCode.EE, /^[0-9]{5}$/],
  [CountryCode.ET, /^[0-9]{4}$/],
  [CountryCode.FK, /^FIQQ1ZZ$/],
  [CountryCode.FO, /^[0-9]{3}$/],
  [CountryCode.FI, /^[0-9]{5}$/],
  [CountryCode.FR, /^[0-9]{5}$/],
  [CountryCode.GF, /^973[0-9]{2}$/],
  [CountryCode.PF, /^987[0-9]{2}$/],
  [CountryCode.GE, /^[0-9]{4}$/],
  [CountryCode.DE, /^[0-9]{5}$/],
  [CountryCode.GI, /^GX111AA$/],
  [CountryCode.GR, /^[0-9]{5}$/],
  [CountryCode.GL, /^[0-9]{4}$/],
  [CountryCode.GP, /^971[0-9]{2}$/],
  [CountryCode.GU, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.GT, /^[0-9]{5}$/],
  [
    CountryCode.GG,
    /([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})/
  ],
  [CountryCode.GN, /^[0-9]{3}$/],
  [CountryCode.GW, /^[0-9]{4}$/],
  [CountryCode.HT, /^[0-9]{4}$/],
  [CountryCode.HM, /^[0-9]{4}$/],
  [CountryCode.VA, /^00120$/],
  [CountryCode.HN, /^(HN)?[0-9]{5}$/],
  [CountryCode.HU, /^[0-9]{4}$/],
  [CountryCode.IS, /^[0-9]{3}$/],
  [CountryCode.IN, /^[0-9]{6}$/],
  [CountryCode.IC, /^[0-9]{5}$/],
  [CountryCode.ID, /^[0-9]{5}$/],
  [CountryCode.IR, /^[0-9]{10}$/],
  [CountryCode.IQ, /^[0-9]{5}$/],
  [
    CountryCode.IE,
    /^[AaC-Fc-fHhKkNnPpRrTtV-Yv-y]\\d[0-9Ww][ -]?[0-9AaC-Fc-fHhKkNnPpRrTtV-Yv-y]{4}$/
  ],
  [
    CountryCode.IM,
    /([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})/
  ],
  [CountryCode.IL, /^[0-9]{7}$/],
  [CountryCode.IT, /^[0-9]{5}$/],
  [CountryCode.JM, /^[0-9]{2}$/],
  [CountryCode.JP, /^[0-9]{7}$/],
  [
    CountryCode.JE,
    /([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})/
  ],
  [CountryCode.JO, /^[0-9]{5}$/],
  [CountryCode.KZ, /^[0-9]{6}$/],
  [CountryCode.KE, /^[0-9]{5}$/],
  [CountryCode.KR, /^[0-9]{5}$/],
  [CountryCode.KW, /^[0-9]{5}$/],
  [CountryCode.KG, /^[0-9]{6}$/],
  [CountryCode.LA, /^[0-9]{5}$/],
  [CountryCode.LV, /^(LV)?[0-9]{4}$/],
  [CountryCode.LB, /^[0-9]{4}(?:[0-9]{4})?$/],
  [CountryCode.LS, /^[0-9]{3}$/],
  [CountryCode.LR, /^[0-9]{4}$/],
  [CountryCode.LY, /^[0-9]{5}$/],
  [CountryCode.LI, /^[0-9]{4}$/],
  [CountryCode.LT, /^(LT)?[0-9]{5}$/],
  [CountryCode.LU, /^(L){0,1}\\d{4}$/],
  [CountryCode.MK, /^[0-9]{4}$/],
  [CountryCode.MG, /^[0-9]{3}$/],
  [CountryCode.MY, /^[0-9]{5}$/],
  [CountryCode.MV, /^[0-9]{5}$/],
  [CountryCode.MT, /^[A-Z]{3}[0-9]{4}$/],
  [CountryCode.MH, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.MQ, /^[0-9]{5}$/],
  [CountryCode.MU, /^[0-9]{5}$/],
  [CountryCode.YT, /^[0-9]{5}$/],
  [CountryCode.MX, /^[0-9]{5}$/],
  [CountryCode.FM, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.MD, /^(MD)?[0-9]{4}$/],
  [CountryCode.MC, /^980[0-9]{2}$/],
  [CountryCode.MN, /^[0-9]{5}$/],
  [CountryCode.ME, /^[0-9]{5}$/],
  [CountryCode.MS, /^(MSR)?[0-9]{4}$/],
  [CountryCode.MA, /^[0-9]{5}$/],
  [CountryCode.MZ, /^[0-9]{4}$/],
  [CountryCode.MM, /^[0-9]{5}$/],
  [CountryCode.NA, /^[0-9]{5}$/],
  [CountryCode.NP, /^[0-9]{5}$/],
  [CountryCode.NL, /^[1-9][0-9]{3}(?!SA|SD|SS)[A-Z]{2}$/],
  [CountryCode.NC, /^988[0-9]{2}$/],
  [CountryCode.NZ, /^[0-9]{4}$/],
  [CountryCode.NI, /^[0-9]{5}$/],
  [CountryCode.NE, /^[0-9]{4}$/],
  [CountryCode.NG, /^[0-9]{6}$/],
  [CountryCode.NF, /^[0-9]{4}$/],
  [CountryCode.MP, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.NO, /^[0-9]{4}$/],
  [CountryCode.OM, /^[0-9]{3}$/],
  [CountryCode.PK, /^[0-9]{5}$/],
  [CountryCode.PW, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.PS, /^[0-9]{3}$/],
  [CountryCode.PA, /^[0-9]{4}$/],
  [CountryCode.PG, /^[0-9]{3}$/],
  [CountryCode.PY, /^[0-9]{4}$/],
  [CountryCode.PE, /^[0-9]{5}$/],
  [CountryCode.PH, /^[0-9]{4}$/],
  [CountryCode.PN, /^PCRN1ZZ$/],
  [CountryCode.PL, /^[0-9]{5}$/],
  [CountryCode.PT, /^([0-9]{4}|[0-9]{7})$/],
  [CountryCode.PR, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.RE, /^974[0-9]{2}$/],
  [CountryCode.RO, /^[0-9]{6}$/],
  [CountryCode.RU, /^[0-9]{3}([0-9]{3})?$/],
  [CountryCode.BL, /^97133$/],
  [CountryCode.SH, /^STHL1ZZ$/],
  [CountryCode.LC, /^LC[0-9]{5}$/],
  [CountryCode.MF, /^97150$/],
  [CountryCode.PM, /^97500$/],
  [CountryCode.VC, /^(VC)?[0-9]{4}$/],
  [CountryCode.WS, /^(WS)?[0-9]{4}$/],
  [CountryCode.SM, /^4789[0-9]{1}$/],
  [CountryCode.SA, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.SN, /^[0-9]{5}$/],
  [CountryCode.RS, /^[0-9]{5}$/],
  [CountryCode.SG, /^[0-9]{6}$/],
  [CountryCode.SK, /^[0-9]{5}$/],
  [CountryCode.SI, /^[0-9]{4}$/],
  [CountryCode.SO, /^[a-zA-Z]{2}[0-9]{5}$/],
  [CountryCode.ZA, /^[0-9]{4}$/],
  [CountryCode.GS, /^SIQQ1ZZ$/],
  [CountryCode.ES, /^[0-9]{5}$/],
  [CountryCode.LK, /^[0-9]{5}$/],
  [CountryCode.SD, /^[0-9]{5}$/],
  [CountryCode.SJ, /^[0-9]{4}$/],
  [CountryCode.SZ, /^[a-zA-Z]{1}[0-9]{3}$/],
  [CountryCode.SE, /^[0-9]{5}$/],
  [CountryCode.CH, /^[0-9]{4}$/],
  [CountryCode.TW, /^[0-9]{3}([0-9]{2})?$/],
  [CountryCode.TJ, /^[0-9]{6}$/],
  [CountryCode.TZ, /^[0-9]{5}$/],
  [CountryCode.TH, /^[0-9]{5}$/],
  [CountryCode.TT, /^[0-9]{6}$/],
  [CountryCode.TN, /^[0-9]{4}$/],
  [CountryCode.TR, /^[0-9]{5}$/],
  [CountryCode.TM, /^[0-9]{6}$/],
  [CountryCode.TC, /^TKCA1ZZ$/],
  [CountryCode.UA, /^[0-9]{5}$/],
  [
    CountryCode.GB,
    /([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})/
  ],
  [CountryCode.US, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.UY, /^[0-9]{5}$/],
  [CountryCode.UZ, /^[0-9]{6}$/],
  [CountryCode.VE, /^[0-9]{4}[a-zA-Z]?$/],
  [CountryCode.VN, /^[0-9]{6}$/],
  [CountryCode.VI, /^[0-9]{5}([0-9]{4})?$/],
  [CountryCode.WF, /^986[0-9]{2}$/],
  [CountryCode.ZM, /^[0-9]{5}$/]
])

export default postCodeRegex
